package org.dbstar.scheduler.control.db.authority;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.object.SqlQuery;

/**
 * 查询所有授权用户
 * 
 * @author 代波
 * @since 1.0.0
 * @version 1.0.0
 * @date 2012-6-5
 */
public class AuthorityQueryUsername extends SqlQuery<String> {
	public AuthorityQueryUsername(JdbcTemplate jdbcTemplate) {
		super();
		setJdbcTemplate(jdbcTemplate);
		setSql("SELECT DISTINCT USERNAME FROM SCHD_AUTHORITY");
	}

	@Override
	protected RowMapper<String> newRowMapper(Object[] parameters, @SuppressWarnings("rawtypes") Map context) {
		return new RowMapper<String>() {
			@Override
			public String mapRow(ResultSet rs, int rowNum) throws SQLException {
				return rs.getString(1);
			}
		};
	}
}
